﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using QLTV_BLL;
using QLTV_Public;


namespace GUI
{
    public partial class uc_GhiMuon : DevExpress.XtraEditors.XtraUserControl
    {
        #region khai bao bien

        DocGia_BLL dg_bll = new DocGia_BLL();
        TextMessageBox box = new TextMessageBox();
        bool isGV = true;
        #endregion


        #region LoadForm
        public uc_GhiMuon()
        {
            InitializeComponent();
        }


        private void uc_GhiMuon_Load(object sender, EventArgs e)
        {
            Load_Data_GiaoVien();
        }

        #endregion

        #region Cac chuc nang

        private void btnGhiMuon_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            frmMuonTaiLieu frm = new frmMuonTaiLieu();
            frm.ShowDialog();
        }

        private void btnGiaoVien_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Load_Data_GiaoVien();
            isGV = true;
        }

        private void btnHocVien_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            Load_Data_HocVien();
            isGV = false;
        }

        private void btnXemChiTiet_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            if(isGV==true)
            {
                if (grv_GiaoVien.RowCount > 0)
                {
                    frmXemChiTiet frm = new frmXemChiTiet();
                    frm.maPhieu = grv_GiaoVien.GetRowCellValue(grv_GiaoVien.FocusedRowHandle, "Mã Phiếu Yêu Cầu").ToString();
                    frm.ShowDialog();
                }
            }
            else
            {
                if (grv_HocVien.RowCount > 0)
                {
                    frmXemChiTiet frm = new frmXemChiTiet();
                    frm.maPhieu = grv_HocVien.GetRowCellValue(grv_HocVien.FocusedRowHandle, "Mã Phiếu Yêu Cầu").ToString();
                    frm.ShowDialog();
                }
            }
        }

        #endregion

        #region ham viet them

        private void Load_Data_HocVien()
        {
            gr_GiaoVien.Hide();
            gr_HocVien.Show();
            gr_HocVien.Dock = DockStyle.Fill;
            grd_HocVien.DataSource = dg_bll.Load_Muon_SinhVien();
            grv_HocVien.BestFitColumns();
        }

        private void Load_Data_GiaoVien()
        {
            gr_HocVien.Hide();
            gr_GiaoVien.Show();
            gr_GiaoVien.Dock = DockStyle.Fill;
            grd_GiaoVien.DataSource = dg_bll.Load_GiaoVien();
            grv_GiaoVien.BestFitColumns();

        }

        #endregion
    }
}
